package com.mzj.saas.mservice.eligible.repository;

import com.mzj.saas.mservice.eligible.entity.HouseApplyFlow;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

public interface HouseApplyFlowRepository extends PagingAndSortingRepository<HouseApplyFlow, Long>, JpaSpecificationExecutor<HouseApplyFlow> {
    @Modifying
    @Query(value = "UPDATE `saas_house_apply_flow` SET next_data_id = ?2 WHERE data_id = ?1", nativeQuery = true)
    int updateByDataId(String dataId, String nextDataId);

    HouseApplyFlow findByApplyCodeAndDataId(String applyCode, String dataId);

    List<HouseApplyFlow> findByApplyCodeAndType(String applyCode, Integer type);

    int deleteByDataId(String dataIds);

    HouseApplyFlow findByDataId(String dataId);

    @Modifying
    @Query(value = "UPDATE `saas_house_apply_flow` SET up_data_id = ?2 WHERE data_id = ?1", nativeQuery = true)
    int updateNextDataIdByDataId(String dataId, String upDataId);
}
